#include "Unsafe.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Unsafe_classType = NULL;
VTable* Unsafe_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Void make(Obj? val) */
void Unsafe_make(Unsafe* self, NullableObj val)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Unsafe.make not implemented yet"));
}


/* Obj? val() */
NullableObj Unsafe_val(Unsafe* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Unsafe.val not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Unsafe_initType(void)
{
  if (Unsafe_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Unsafe_initVTable();
    Type* type = Type_new("Unsafe", baseType, vtable, sizeof(Unsafe), sizeof(UnsafeVTable));
    Type_registerCtorImplementation(type, "make", Unsafe_make, 1);
    Type_registerMethodImplementation(type, "val", Unsafe_val, 0);
    Unsafe_classType = type;
    Unsafe_initStatic();
  }
  return Unsafe_classType;
}


VTable* Unsafe_initVTable(void)
{
  if (Unsafe_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(UnsafeVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    Unsafe_classVTable = vtable;
  }
  return Unsafe_classVTable;
}


void Unsafe_initStatic(void)
{
}
